﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Maticsoft.Web.Admin.Shopping
{
    public partial class ProductPicList : PageBase
    {
        BLL.ProductPics bll = new BLL.ProductPics();
        int _ProductId;
        protected void Page_Load(object sender, EventArgs e)
        {
            Check("shopping", "modify");

            int.TryParse(Request.QueryString["id"], out _ProductId);
            if (!IsPostBack)
            {
                BindData();
            }
        }

        protected void BindData()
        {
            string strWhere = "IsActive=1 and ProductId=" + _ProductId;
            DataSet ds = bll.GetListByPage(strWhere, "ProductPicId desc", 1, 1000);
            Repeater1.DataSource = ds.Tables[0].DefaultView;
            Repeater1.DataBind();
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            if (txtIds.Value.Trim() != "")
            {
                foreach (string s in txtIds.Value.Trim().Split(','))
                {
                    Response.Write(s);
                    bll.Delete(int.Parse(s));
                }

                BLL.Log logBLL = new BLL.Log();
                Model.Log logModel = new Model.Log();
                logModel.LogTitleId = 3;
                logModel.ObjectId = 0;
                logModel.UserId = int.Parse(UserId);
                logModel.LogDesc = ManagerName + " 删除图片,图片编号：" + txtIds.Value;
                logModel.CreateTime = DateTime.Now;
                logBLL.Add(logModel);
            }

            Response.Redirect("ProductPicList.aspx?act=add&id=" + _ProductId);
        }
    }
}